<template>
  <div class="dashboard-editor-container">
    <branch-group :dailData="dailData"/>
    <!--    <AgentData :isCommon="true"></AgentData>-->
    <!--    <StoreData :isCommon="true"></StoreData>-->
    <!--  系统公告和ERP消息  -->
    <div class="flex-between">
      <el-card class="box-card" style="width: 45%">
        <div slot="header" class="flex flex-between">
          <span>系统公告</span>
          <el-button type="text">
            更多
            <i class="el-icon-d-arrow-right"></i>
          </el-button>
        </div>
        <div v-for="o in 4" :key="o" class="text item">
          {{ '列表内容 ' + o }}
        </div>
      </el-card>
      <el-card class="box-card" style="width: 45%">
        <div slot="header" class="flex flex-between">
          <span>ERP消息</span>
          <el-button type="text"> 更多
            <i class="el-icon-d-arrow-right"></i>
          </el-button>
        </div>
        <div v-for="o in 4" :key="o" class="text item">
          {{ '列表内容 ' + o }}
        </div>
      </el-card>
    </div>
<!--    <notice/>-->
  </div>
</template>

<script>
import BranchGroup from '../../dashboard/BranchGroup'
import BonusBranch from '../../dashboard/BonusBranch'
import Notice from '../../dashboard/Notice'
import {
  BranchOfficeDailData,
  BranchOfficeAgentSaleRankingMonthData,
  BranchOfficeShopSaleRankingMonthData
} from "@/api/index/index"
import StoreData from "@/views/dataSearch/storeData.vue";
import AgentData from "@/views/dataSearch/agentData.vue";

export default {
  name: 'branchPage',
  components: {
    BranchGroup,
    BonusBranch,
    Notice,
    StoreData,
    AgentData
  },
  data() {
    return {
      tableData: [],
      dailData: {},
      dpxsData: [],
      dlxsData: [],
      dpxsloading: true,
      dlxsloading: true,
      dlxsParams: {
        pageSize: 10,
        pageNum: 1
      },
      dpxsParams: {
        pageSize: 10,
        pageNum: 1
      },
      dpxstotal: 0
    }
  },
  created() {
    this.getBranchOfficeDailData();
    this.getBranchOfficeAgentSaleRankingMonthData();
    this.getBranchOfficeShopSaleRankingMonthData();
  },
  methods: {
    // 实时数据
    getBranchOfficeDailData() {
      BranchOfficeDailData().then(res => {
        this.dailData = res.data;
      })
    },
    // 代理销售排行（销售金额累计TOP10）
    getBranchOfficeAgentSaleRankingMonthData() {
      this.dlxsloading = true;
      BranchOfficeAgentSaleRankingMonthData(this.dlxsParams).then(res => {
        this.dlxsData = res.rows;
        this.dlxsloading = false;
      })
    },
    // 近一个月店铺销售排行（销售金额累计TOP20）
    getBranchOfficeShopSaleRankingMonthData() {
      this.dpxsloading = true;
      BranchOfficeShopSaleRankingMonthData(this.dpxsParams).then(res => {
        this.dpxsData = res.records;
        this.dpxstotal = res.total;
        this.dpxsloading = false;
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 20px 16px 0;
    margin-bottom: 32px;

    .chart-wrapper-box {
      padding-bottom: 20px;
    }

    p {
      font-size: 16px;
      line-height: 18px;
      margin: 0 0 15px;
      color: #666;
    }
  }
}
</style>
